package com.hero.jobweb.action.personal;

import com.hero.basicsystem.entity.User;
import com.hero.jobweb.action.JobWebBaseAction;
import com.hero.jobweb.action.common.LoginAction;
import com.hero.jobweb.config.ExceptionKey;
import com.hero.jobweb.exception.BaseException;
import com.hero.jobweb.service.IPersonalService;

public class PersonalAction extends JobWebBaseAction {

	private enum PersonalActionKey
	{
		INDEX("index");
		private String value;
		private PersonalActionKey(String value)
		{
			this.value=value;
		}
		@Override
		public String toString() {
			return value;
		}
	}
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private User user = new User();
	private String confirmPassword;

	public String getConfirmPassword() {
		return confirmPassword;
	}

	public void setConfirmPassword(String confirmPassword) {
		this.confirmPassword = confirmPassword;
	}

	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	private IPersonalService personalService = (IPersonalService) getBean("personalServiceImpl");

	/**
	 * 个人管理平台首页
	 * 
	 * @return
	 */
	public String index() {
		this.personalService.queryPersonalIndex(null);
		return PersonalActionKey.INDEX.toString();
	}

	/**
	 * 个人用户注册
	 * 
	 * @return
	 */
	public String sign() {
		try {
			personalService.jtaSavePersonalUser(user);
		} catch (BaseException be) {
			addFieldError(ExceptionKey.USER_SIGN_ERROR.toString(),be.getMessage());
			return INPUT;
		}
		LoginAction loginAction = new LoginAction();
		loginAction.getTbUser().setNAME(user.getName());
		loginAction.getTbUser().setPASSWORD(user.getPassword());
		return loginAction.userLogin();
	}

}
